<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/pages/safeai/jsp/common/taglibs.jsp"%>
<html>
	<head>
		<title>增加记录</title>
		<link href="${ctx}/css/safeai/together.css" rel="stylesheet" type="text/css">
		<link type="text/css" rel="StyleSheet" media="all" href="${ctx}/css/combined.css">
		<link type="text/css" rel="StyleSheet" media="all" href="${ctx}/css/global.css">
		<script type="text/javascript" src="${ctx}/js/calendar.js"></script>
        <script type="text/javascript" src="${ctx}/js/calendar-zh.js"></script>
        <script type="text/javascript" src="${ctx}/js/calendar-setup.js"></script>
		  <script type="text/javascript">
            // Hack to avoid bug in jscalendar - JRA-7713
            if (!Calendar._TT["WEEKEND"]) Calendar._TT["WEEKEND"] = "0,6";
            if (!Calendar._TT["DAY_FIRST"]) Calendar._TT["DAY_FIRST"] = "Display %s first";
        </script>
		<script type="text/javascript" src="${ctx}/script/common/common.js"></script>
		<%@ include file="/pages/safeai/jsp/common/meta.jsp"%>
	</head>
	<body>
	<form action="${ctx}/point.do?method=addPointRecord" name="pointRecordForm" method="post">
		 <table width="600px" align="center">
		 	 <input type="hidden" name="point.customerId" value="${uid}"/> 
             <tr>
		    	<th colspan="2" class="td_01" height="25px">添加记录</th>
	    	 </tr> 
			 <tr>
		    	<td class="td_3">积分增减(-为减积分)：</td>
		    	<td class="td_04"><input type="text" id="point" maxlength="11" name="point.point"/></td>
	   		 </tr> 
	   		  <tr>
		    	<td class="td_3">滞留金增减(-为减滞留金)：</td> 
		    	<td class="td_04"><input type="text" id="cash" maxlength="11" name="point.cash"/></td>
	   		 </tr>
	   		  <tr>
		    	<td class="td_3">发生原因：</td>
		    	<td class="td_04"><textarea id="content" name="point.content"></textarea></td>
	   		 </tr>
	   		  <tr>
		    	<td class="td_3">发生日期：</td>
		    	<td class="td_04">
		    		<input name="point.shoppingDateStr" id="created:after" type="text" / style="background-image:url(${ctx}/images/cal.gif); background-repeat:no-repeat; background-position:left;padding-left:25px; cursor:hand;width:176px"> 
					<script type="text/javascript">
						    Calendar.setup({
						
						        firstDay       :    0,                  // first day of the week
						        inputField     :    "created:after",     // id of the input field
						        button         :    "created:after_trigger_c",  // trigger for the calendar (button ID)
						        align          :    "Bl",           // alignment (defaults to "Bl")
						        singleClick    :    true,
						             ifFormat       : "%y/%m/%d"      // our date only format
						         });
		                 </script>	    	    </td>
	   		 </tr>
			 <tr>
				<td colspan="2" align="center">
					<input type="submit" value="提交" class="btn" onclick="return check();"/>                </td>
			</tr>
	    </table>
	</form>
	</body>
</html>
<script language="javascript">  
	function check() {
		var point = window.pointRecordForm.point.value;
		var cash = window.pointRecordForm.cash.value;
		var content = window.pointRecordForm.content.value;
		var created = document.getElementById("created:after").value;
		
		if(point==""&&cash==""){
					alert("积分增减值和滞留金增减必添一项!");
					return false;
				}else{
					if(point.length>11){
					alert("积分增减最长为11位!");
					return false;
					}
					if(cash.length>11){
						alert("滞留金增减最长为11位!");
						return false;
					}
					var cashpd;
					var pd=cash.indexOf("\.");
					var chang = cash.substr(pd+1,cash.length);
					if(pd!==-1){
						if(chang.length>2){
						alert("滞留金小数点后只充许有两位!");
						return false;
					}
					}
					if(pd){
						var cashpd=cash.substr(0,pd)+cash.substr(pd+1,cash.length);
					}
					var Letters = "0123456789";
					var c;
				 	for( i = 0; i < point.length+1; i ++ ){					
					  	c = point.charAt(i);
					  	if(c=="-"&&i==0){
					  		i=i+1;
					  		c=point.charAt(i);
					  	}
						if (Letters.indexOf(c) !=c){
							alert("积分增减不能包含字符!");
							return false;
						}
					}
					for( i = 0; i < cashpd.length; i ++ ){					
					  	c = cashpd.charAt(i);
					  	if(c=="-"&&i==0){
					  		i=i+1;
					  		c=cashpd.charAt(i);
					  	}
						if (Letters.indexOf(c) !=c){
							alert("滞留金增减不能包含字符!");
							return false;
						}
					}
				}
				if(content!=""){
					if(content.length>255){
						alert("发生原因最大长度为255个字符!");
						return false;
					}
				}else{
					alert("发生原因内容不可为空!");
					return false;
				}
				if(created==""){
					alert("请选择发生日期");
					return false;
				}
	}
</script>